home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / glibmm-2.4 / glibmm / optiongroup.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-04-20  |  4.1 KB  |  142 lines

  1. // -*- c++ -*-
  2. // Generated by gtkmmproc -- DO NOT MODIFY!
  3. #ifndef _GLIBMM_OPTIONGROUP_H
  4. #define _GLIBMM_OPTIONGROUP_H
  5.  
  6.  
  7. /* $Id: optiongroup.hg,v 1.10 2005/01/10 17:42:17 murrayc Exp $ */
  8.  
  9. /* Copyright (C) 2004 The glibmm Development Team
  10.  *
  11.  * This library is free software; you can redistribute it and/or
  12.  * modify it under the terms of the GNU Library General Public
  13.  * License as published by the Free Software Foundation; either
  14.  * version 2 of the License, or (at your option) any later version.
  15.  *
  16.  * This library is distributed in the hope that it will be useful,
  17.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  19.  * Library General Public License for more details.
  20.  *
  21.  * You should have received a copy of the GNU Library General Public
  22.  * License along with this library; if not, write to the Free
  23.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  */
  25.  
  26.  
  27. #include <glibmm/ustring.h>
  28. #include <map>
  29. #include <vector>
  30. #include <glib/goption.h> //TODO: Try to hide this.
  31.  
  32.  
  33. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  34. extern "C" { typedef struct _GOptionGroup GOptionGroup; }
  35. #endif //DOXYGEN_SHOULD_SKIP_THIS
  36.  
  37.  
  38. namespace Glib
  39. {
  40.  
  41. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  42. class OptionEntry;
  43. class OptionContext;
  44. #endif //DOXYGEN_SHOULD_SKIP_THIS
  45.  
  46. /** An OptionGroup defines the options in a single group. 
  47.  * Libraries which need to parse commandline options are expected to provide a function that allows their OptionGroups to
  48.  * be added to the application's OptionContext.
  49.  */
  50. class OptionGroup
  51. {
  52.   public:
  53. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  54.   typedef OptionGroup CppObjectType;
  55.   typedef GOptionGroup BaseObjectType;
  56. #endif /* DOXYGEN_SHOULD_SKIP_THIS */
  57.  
  58. private:
  59.  
  60. public:
  61.   OptionGroup(const Glib::ustring& name, const Glib::ustring& description, const Glib::ustring& help_description = Glib::ustring());
  62.  
  63.   /** This always takes ownership of the underlying GOptionGroup, 
  64.    * so it is only useful with C functions that return newly-allocated GOptionGroups. 
  65.    */
  66.   explicit OptionGroup(GOptionGroup* castitem);  
  67.   
  68.   virtual ~OptionGroup();
  69.   
  70.  
  71.   virtual bool on_pre_parse(OptionContext& context, OptionGroup& group);
  72.   virtual bool on_post_parse(OptionContext& context, OptionGroup& group);
  73.   virtual void on_error(OptionContext& context, OptionGroup& group);
  74.   
  75.   
  76.   void add_entry(const OptionEntry& entry);
  77.   
  78.   
  79.   typedef std::vector<Glib::ustring> vecustrings;
  80.   typedef std::vector<std::string> vecstrings;
  81.   
  82.   void add_entry(const OptionEntry& entry, bool& arg);
  83.   void add_entry(const OptionEntry& entry, int& arg);
  84.   void add_entry(const OptionEntry& entry, Glib::ustring& arg);
  85.   void add_entry_filename(const OptionEntry& entry, std::string& arg);  
  86.   void add_entry(const OptionEntry& entry, vecustrings& arg);
  87.   void add_entry_filename(const OptionEntry& entry, vecstrings& arg);
  88.     
  89. /* TODO:
  90. void          g_option_group_set_translate_func     (GOptionGroup       *group,
  91.                              GTranslateFunc      func,
  92.                              gpointer            data,
  93.                              GDestroyNotify      destroy_notify);
  94. */
  95.   
  96.   /** A convenience function to use gettext() for translating
  97.    * user-visible strings. 
  98.    * 
  99.    * Since: 2.6
  100.    * @param domain The domain to use.
  101.    */
  102.   void set_translation_domain(const Glib::ustring& domain);
  103.   
  104.   GOptionGroup*       gobj()       { return gobject_; }
  105.   const GOptionGroup* gobj() const { return gobject_; }
  106.   GOptionGroup* gobj_give_ownership();
  107.   
  108. protected:
  109.  
  110.   class CppOptionEntry
  111.   {
  112.   public:
  113.     CppOptionEntry();
  114.     
  115.     void allocate_c_arg();
  116.     void convert_c_to_cpp();
  117.     void release_c_arg();
  118.   
  119.     GOptionArg carg_type_;
  120.     void* carg_;
  121.     void* cpparg_;
  122.     OptionEntry* entry_;
  123.   };
  124.   
  125.   void add_entry_with_wrapper(const OptionEntry& entry, GOptionArg arg_type, void* cpp_arg);
  126.   
  127.   //Map of entry names to CppOptionEntry:
  128.   typedef std::map<Glib::ustring, CppOptionEntry> type_map_entries;
  129.   type_map_entries map_entries_;
  130.   
  131.   GOptionGroup* gobject_;
  132.   bool has_ownership_; //Whether the gobject_ belongs to this C++ instance.
  133.  
  134.  
  135. };
  136.  
  137. } // namespace Glib
  138.  
  139.  
  140. #endif /* _GLIBMM_OPTIONGROUP_H */
  141.  
  142.